package cn.com.roy.thread.t7_4_3.formatOk2;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Mythread extends Thread {
    private SimpleDateFormat sdf ;
    private String dateString;

    public Mythread(SimpleDateFormat sdf,String dateString){
        this.sdf = sdf;
        this.dateString = dateString;
    }

    @Override
    public void run() {
        super.run();
        try {
            Date dateRef = DateUtils.getSimpleDateFormat("yyyy-MM-dd").parse(dateString);
            String newDateString = DateUtils.getSimpleDateFormat("yyyy-MM-dd").format(dateRef);
            if(!newDateString.equals(dateString)){
                System.out.println("ThreadName = " +
                this.getName()+ "报错了，日期字符串：" + dateString +
                "转成的日期为：" + newDateString
                );
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
